package com.fj.controller;

import cn.hutool.core.util.RandomUtil;
import com.fj.response.Result;
import com.fj.service.SendSmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sends")
@CrossOrigin
@Api(value = "系统短信模块",tags = "系统短信接口")
public class SendSmsController {

    @Autowired
    private SendSmsService sendSmsService;

    @ApiOperation(value = "手机验证码", notes = "获取手机验证码")
    @PostMapping("/send")
    public Result send(String phoneNumber){
        String verification=RandomUtil.randomNumbers(6);
        sendSmsService.sendSms(phoneNumber, verification);
        return  Result.ok().data("verification", verification);
    }
}
